package com.kaisu.blog.domain.user.repository;

import com.kaisu.blog.domain.user.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @author kaisu
 */
public interface UserRepository {
    /**
     * save
     *
     * @param user user
     */
    void save(User user);

    /**
     * find
     *
     * @param id id
     * @return user
     */
    User findById(String id);

    boolean checkUnique(User user);

    /**
     * find by username
     *
     * @param username username
     * @return user
     */
    User findByAccount(String username);

    /**
     * find all by account
     *
     * @param usernames user names
     * @return users
     */
    Collection<User> findAllByAccount(Collection<String> usernames);

    /**
     * find by ids
     *
     * @param ids ids
     * @return user list
     */
    Set<User> findByIds(Set<String> ids);

    /**
     * page
     *
     * @param condition condition
     * @param pageable  page
     * @return page user
     */
    Page<User> page(String condition, Pageable pageable);

    /**
     * batch save
     *
     * @param userList userList
     */
    void saveBatch(List<User> userList);
}
